import React from "react";
//3. 导入 Context 对象
import { StrContext } from "./Context"; 

export default function B() {
    //4. 获取数据
    let {count, setCount} = React.useContext(StrContext);

    //声明函数
    const add = () => {
        setCount(count + 1);
    }

    return (
        <div>
            <div>B</div>
            <h3>{count}</h3>
            <button onClick={add}>自增</button>
        </div>
    );
}
